from django.urls import path
from rest_framework.routers import DefaultRouter

from demo.views import StudentViewSet, ClassesViewSet

urlpatterns = [
    # 视图不会识别 get post put delete
    # 根据功能来添加get请求 或 post请求
    # path('students/',StudentViewSet.as_view({'get': "list","post":"create"})),
    # path('students/<int:pk>/',StudentViewSet.as_view({'get': "retrieve","put":"update","delete":"destroy"})),
]
# 创建路由器对象来自动生成路由
router = DefaultRouter()
# 注册路由
# 参数：路由名 视图集类

# 生成的路由为/classes
router.register("classes", ClassesViewSet)
router.register("students", StudentViewSet)

# 获取生成的路由信息，得到的是一个列表类型，所以直接用+号
urlpatterns += router.urls
